package com.example.dell.xpexpressiondemo;

import android.graphics.Bitmap;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.library.XPExpressionView;
import com.example.library.XPTextUtils;

public class MainActivity extends AppCompatActivity {
    private RelativeLayout xp_test_layout;
    private TextView xp_test_tv;
    private EditText xp_test_et;
    private Button xp_test_btn;
    private XPTextUtils xpTextUtils;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        xp_test_layout = (RelativeLayout) findViewById(R.id.xp_test_layout);
        xp_test_layout.addView(new XPExpressionView(MainActivity.this));
        xp_test_tv = (TextView) findViewById(R.id.xp_test_tv);
        xp_test_et = (EditText) findViewById(R.id.xp_test_et);
        xp_test_btn = (Button) findViewById(R.id.xp_test_btn);
        xpTextUtils = new XPTextUtils(xp_test_et, MainActivity.this);
        xp_test_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                xpTextUtils.setExpressionText(MainActivity.this, xp_test_tv, xp_test_et.getText().toString());
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        xpTextUtils.recycle();
    }
}
